// Copyright (c) 2022 CHANGLEI. All rights reserved.

import 'package:aircraft_war/generated/assets.dart';
import 'package:flame/components.dart';
import 'package:flame/parallax.dart';
import 'package:flutter/widgets.dart' as widgets;

const _speed = 120.0;

final _images = [
  ParallaxImageData(Images.background),
];

/// Created by changlei on 2022/5/16.
///
/// 背景
class GameBackground extends PositionComponent {
  @override
  Future<void> onLoad() async {
    await add(await ParallaxComponent.load(
      _images,
      baseVelocity: Vector2(0, -_speed),
      repeat: widgets.ImageRepeat.repeatY,
      anchor: Anchor.topLeft,
      fill: LayerFill.width,
    ));
  }
}
